home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_360 / uucp / uucp0.lzh / src / lib / string.c < prev    next >
C/C++ Source or Header  |  1990-04-04  |  868b  |  53 lines

  1.  
  2. /*
  3.  *  STRING.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/lib/RCS/string.c,v 1.1 90/02/02 12:08:41 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include "config.h"
  12.  
  13. Prototype int strcmpi(const char *, const char *);
  14. Prototype int strncmpi(const char *, const char *, int);
  15.  
  16. int
  17. strcmpi(s, d)
  18. const char *s;
  19. const char *d;
  20. {
  21.     short c1, c2;
  22.     for (;;) {
  23.     c1 = *s++;
  24.     c2 = *d++;
  25.  
  26.     if (c1 == 0 || c2 == 0)
  27.         return(c1 || c2);   /*  0= both are 0   */
  28.     if (((c1 ^ c2) | 0x20) != 0x20)
  29.         return(1);
  30.     }
  31.     return(0);
  32. }
  33.  
  34. int
  35. strncmpi(s, d, n)
  36. const char *s;
  37. const char *d;
  38. int n;
  39. {
  40.     short c1, c2;
  41.     while (n--) {
  42.     c1 = *s++;
  43.     c2 = *d++;
  44.  
  45.     if (c1 == 0 || c2 == 0)
  46.         return(c1 || c2);   /*  0= both are 0   */
  47.     if (((c1 ^ c2) | 0x20) != 0x20)
  48.         return(1);
  49.     }
  50.     return(0);
  51. }
  52.  
  53.